<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/style.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/admin.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/common.css" />
	<script src="<%=basePath%>js/json.js" type="text/javascript"></script>
	<script src="<%=basePath%>js/prototype.js" type="text/javascript"></script>
	<script src="<%=basePath%>js/sys/turnPage.js" type="text/javascript"></script>
	<script type="text/javascript" src="<%=basePath%>js/tree/Tree.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/tree/TreeNode.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/sys/roleMenu.js"></script>
	<script type="text/javascript">
		var judgment;
		function check(){
			if(save()){
				return true;
			}else{
				return false;
			}
		}

		function changeChildNode(id){
			var url ="<%=basePath%>admin/system/rightsMgmt/role!changeChildNode.action?id="+id;
			var temp=document.getElementById("num"+id).checked;
			if(id==0){
				var nums=document.getElementsByName("num");
				for(var i=0;i<nums.length;i++){
					nums[i].checked=temp;
				}
			}else{
				new Ajax.Request(url,{method:'post',asynchronous:false,
		           	onComplete:function(json){
			        	var childRole=json.responseText.parseJSON().childRole;
			        	if(childRole!=""){
			        		var strs=childRole.split("`");
						    for(var i=0;i<strs.length;i++){
						    	document.getElementById("num"+strs[i]).checked=temp;
						    }
			        	}
		           }
		        });
			}
		}
	</script>
	<style type="text/css">
	 .linkUseless{poorfish:expression(this.onclick=function kill(){return false})}
	</style>
  </head>
  <body>
  	<form id="form1" name="form1" method="post" action="<%=basePath%>admin/system/rightsMgmt/role!editRoleMenu.action" onsubmit="return check();">
  	<div style="overflow:auto;width:1170px;height:530px">
  	<table height="60%" align="center" cellSpacing=0 cellPadding=0 width="95%">
		    <tr>
		      <td width=10 height=29><img src="images/tree/bg_left_tl.gif"></td>
		      <td 
		    	style="FONT-SIZE: 18px; BACKGROUND-IMAGE: url(images/tree/bg_left_tc.gif); COLOR: white; FONT-FAMILY: system">菜单权限</td>
		      <td width=10>
		      	<IMG src="images/tree/bg_left_tr.gif">
		      	<input type="hidden" id="itemsVal" name="itemsVal"/>
		      	<input type="hidden" id="id" name="id" value="${role.id}"/>
		      </td>
		    </tr>
    		<tr>
		      <td style="BACKGROUND-IMAGE: url(images/tree/bg_left_ls.gif)"></td>
		      <td id=menuTree 
		    	style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; HEIGHT: 100%; BACKGROUND-COLOR: white" 
		    	vAlign=top></td>
		      <td style="BACKGROUND-IMAGE: url(images/tree/bg_left_rs.gif)"></td>
		    </tr>
		    <tr>
	          <td width=10></td>
	          <td align="center"><input type="submit" name="Submit" value="修改" class="Button" /><input type="button" name="Submit22" value="返回" class="Button"  onclick="history.back();"/></td>
	          <td width=10></td>
	        </tr>
		    <tr>
		      <td width=10><IMG src="images/tree/bg_left_bl.gif"></td>
		      <td style="BACKGROUND-IMAGE: url(images/tree/bg_left_bc.gif)"></td>
		      <td width=10><img 
				src="images/tree/bg_left_br.gif"></td>
		    </tr>
	</table>
	</div>
	</form>  
	<script type=text/javascript>
		var tree = null;
		var root = new TreeNode('系统菜单','0','','${roleMenuStr}');
	    <c:forEach var="menu1" items="${menuList}" varStatus="tag">
    		var fun${tag.count}= new TreeNode('${menu1.name}','${menu1.id}','','${roleMenuStr}');
    		<c:forEach var="menu2" items="${menu1.list}" varStatus="tag2">
    			var funb${tag2.count}= new TreeNode('${menu2.name}','${menu2.id}','icon','${roleMenuStr}');
    			fun${tag.count}.add(funb${tag2.count});
    		</c:forEach>
			root.add(fun${tag.count});
		</c:forEach>
		tree = new Tree(root);
		tree.show('menuTree')
	</script>
</body>
</html>
